//
//  UITextField+LeftViewMode.m
//  MUBATE
//
//  Created by sunbin on 2017/2/15.
//  Copyright © 2017年 Quanli. All rights reserved.
//

#import "UITextField+LeftViewMode.h"

@implementation UITextField (LeftViewMode)
- (void)leftViewModeWithConstrainedToWidth:(CGFloat)leftWidth text:(NSString *)leftStr fon:(CGFloat)leftFonSize setFont:(CGFloat)textFon leftTextColor:(UIColor *)leftTextColor bodyTextColor:(UIColor *)bodyTextColor PlaceholderColor:(UIColor *)PlaceholderColor setPlaceholder:(NSString *)placeholder isLaunch:(BOOL)launch{

    [self setTextColor:bodyTextColor];
    [self setPlaceholder:placeholder];
    NSString *FonTNAME = launch?@"FZHei-B01S":@"Microsoft YaHei";

    [self setPlaceholderColor:PlaceholderColor];

    [self setFont:FONT(FonTNAME ,textFon)];
    CGFloat labForwidth = [leftStr stringWidthtWithFont:FONT(FonTNAME, leftFonSize) width:self.frame.size.height];
    UILabel *accountIDLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, labForwidth+5, self.frame.size.height)];
    accountIDLab.text = leftStr;
    accountIDLab.font = FONT(FonTNAME, leftFonSize);
    [accountIDLab setTextColor:leftTextColor];
    self.leftView = accountIDLab;
    self.leftViewMode = UITextFieldViewModeAlways;
}

@end
